﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls; 
using Microsoft.JCI.Common.Entity;
using Microsoft.JCI.Common.Utility;
using Microsoft.JCI.Bll;
namespace Microsoft.JCI.Portal
{
    public class BaseControl : System.Web.UI.UserControl
    {
        /// <summary>
        /// 当前登录用户
        /// </summary>
        protected Guid CurrentUserID
        {
            get
            {
                if (Session[DeclareHelper.SessionConstant.CurrentUserID] == null)
                {
#if DEBUG
                    //Session[DeclareHelper.SessionConstant.CurrentUserID] = new Guid("11111111-1111-1111-1111-111111111111");
                    //return new Guid(Session[DeclareHelper.SessionConstant.CurrentUserID].ToString());

                    return Guid.Empty;
#else
                    return Guid.Empty;
#endif
                }
                else
                {
                    return new Guid(Session[DeclareHelper.SessionConstant.CurrentUserID].ToString());
                }
            }
        }

        /// <summary>
        /// 当前用户实体
        /// </summary>
        protected SysUserEntity CurrentUserEntity
        {
            get
            {
                try
                {
                    if (HttpContext.Current.Session[DeclareHelper.SessionConstant.CurrentUserEntity] == null)
                    {
                        HttpContext.Current.Session[DeclareHelper.SessionConstant.CurrentUserEntity] = new SystemBll().Get<SysUserEntity>(CurrentUserID);
                    }

                    SysUserEntity sessionUser = (SysUserEntity)Session[DeclareHelper.SessionConstant.CurrentUserEntity];

                    return sessionUser;
                }
                catch
                {
                    return null;
                }
            }
        }
    }
}
